#ifndef CREFCOUNTER_H
#define CREFCOUNTER_H

class CRefCounter
{
public:
   CRefCounter() : miRef(1) {}
   virtual ~CRefCounter() {}

   inline int addRef()
   {
      return ++miRef;
   }

   inline int release()
   {
      int iRef = --miRef;
      if(iRef == 0)
      {
         delete this;
      }
      return iRef;
   }

protected:
   int miRef;
};

#endif//CREFCOUNTER_H